/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ManagedBeans;

import Beans.Message;
import dao.MessageDao;
import java.io.Serializable;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;

/**

 @author Marie-Claude
 */
@ManagedBean(name = "reader")
@RequestScoped
public class MessageReaderManager implements Serializable {

  private Message message;
  private String sendToUsername;//INITIALISÉ
  private int sendToUserId;
  @ManagedProperty(value = "#{userManager}")
  private UserManager mbUser;
  @ManagedProperty(value = "#{messageManager}")
  private MessageManager mbMessage;

  /**
   Creates a new instance of MessageReaderManager
   */
  public MessageReaderManager() {
  }

  public Message getMessage() {
    return message;
  }

  public void setMessage(Message message) {
    this.message = message;
  }

  public UserManager getMbUser() {
    return mbUser;
  }

  public void setMbUser(UserManager mbUser) {
    this.mbUser = mbUser;
  }

  public MessageManager getMbMessage() {
    return mbMessage;
  }

  public void setMbMessage(MessageManager mbMessage) {
    this.mbMessage = mbMessage;
  }

  public String getSendToUsername() {
    return sendToUsername;
  }

  public void setSendToUsername(String sendToUsername) {
    this.sendToUsername = sendToUsername;
  }

  public int getSendToUserId() {
    return sendToUserId;
  }

  public void setSendToUserId(int sendToUserId) {
    this.sendToUserId = sendToUserId;
  }

  @PostConstruct
  public void init() {
    message = MessageDao.getMessageById(mbMessage.getSelectedMessageId());
    sendToUsername = mbMessage.getSelectedUsername();
  }

  public String reply(String username) {
    return "reply";
  }
}
